package lexical.domain;

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;

/**
 * Program internal form class
 * 
 * @author Boghy
 * 
 */
public class PIF {
	private List<Integer> codeList = new ArrayList<Integer>();
	private List<Integer> stPositionList = new ArrayList<Integer>();

	public PIF() {}

	public void add(int tokenCode, int stPosition) {
		codeList.add(tokenCode);
		stPositionList.add(stPosition);
	}
	
	public List<Integer> getTokenCodes(){
		return codeList;
	}

	public void print(PrintStream printer) {
		printer.println("#################################################");
		printer.println("########## Program Internal Form - PIF ##########");
		printer.println("#################################################");
		printer.println("TokenCode | ST Position");
		printer.println();
		for (int i = 0; i < codeList.size(); i++) {
			printer.println(String.format("%10d|%10d", codeList.get(i),
					stPositionList.get(i)));
		}
	}

	private class PifEntry {
		private Integer tokenCode;
		private Integer StPosition;

		PifEntry() {
		}

		PifEntry(Integer tokenCode, Integer StPosition) {
			this.tokenCode = tokenCode;
			this.StPosition = StPosition;
		}

		public Integer getTokenCode() {
			return tokenCode;
		}

		public void setTokenCode(Integer tokenCode) {
			this.tokenCode = tokenCode;
		}

		public Integer getStPosition() {
			return StPosition;
		}

		public void setStPosition(Integer stPosition) {
			StPosition = stPosition;
		}
		
	}

}
